pluginHome = new File("./plugins").listFiles().find { it.name.startsWith('cloud-tools-')}
if(pluginHome == null) pluginHome = "."

includeTargets << new File( "${pluginHome}/scripts/CloudToolsInit.groovy" )

target('default': "Enables Master Backups") {
	enableMasterBackups()
}

target(enableMasterBackups: "The implementation task") {
	depends( initCloudToolsService)
	
	def awsProperties = cloudToolsService.makeAWSProperties()
	
    cloudToolsService.withCluster { clusterManager, clusterName, cluster ->
		def bucket = awsProperties.accessKey + "." + System.getProperty("grails.env") + "-" + grailsAppName + "-" + clusterName + "-backups"
		cluster.getClusterInstance().getDatabaseTier().configureMasterBackup(bucket, "backup");
		event('StatusFinal', ['Done enabling master backups'])
	}
}
